package helper;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
    
    public static Date converterStringParaData(String dataEmString) throws Exception{
        try{
            return new SimpleDateFormat("dd/MM/yyyy").parse(dataEmString);
        }catch(Exception e){
            throw new Exception("String de data inválido.");
        }
    }
    
    public static String removerZerosDaFrenteDeStringNumerica(String str) throws Exception{
        if (str.matches("\\d+"))
            return str.replaceAll("^0+", "");
        throw new Exception("String nao contem apenas caracteres numericos.");
    }
}
